import React, { Component } from 'react'
import './index.css'
export default class Footer extends Component {
  render() {
    let {todos, checkAll,clearDone} = this.props
    let hasdo = todos.reduce((pre, cur)=>pre + cur.isDone, 0)
    let total = todos.length
    return (
        <div className="todo-footer">
        <label>
          <input type="checkbox" checked={hasdo === total && total > 0}  onChange={(e)=> {
            console.log(e.target.checked);
            checkAll(e.target.checked)
          }}/>
        </label>
        <span>
          <span>已完成{hasdo}</span> / 全部{total}
        </span>

        <button className="btn btn-danger" onClick={clearDone}>清除已完成任务</button>
      </div>
    )
  }

}
